#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define maxn 100005
int N, K;

int main()
{
	scanf("%d%d", &N, &K);
	int remainder_count[maxn] = { 0 };
	remainder_count[0] = 1;
	long long total=0;
	long long count=0;
	int sum;
	for (int i = 0; i < N; i++)
	{
		scanf("%d",&sum);
		total += sum;
		int remainder = total % K;
		count += remainder_count[remainder];
		remainder_count[remainder]++;
	}
	printf("%lld", count);
	return 0;
}